<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>用户信息管理</title>
    <#include "../../common/link.ftl">
    <script>
        $(function () {
            // 简介查看
            $(".lookBtn1").click(function () {
                //数据复原
                $("#editForm1 textarea").val('')
                $("#editForm1").clearForm(true);

                // 根据id查询简介
                var data = $(this).data("json");
                if(data){
                    $("#editForm1 textarea[name='synopsis']").val(data);
                }
                $("#inputSynModal").modal('show');
            })

            // 详细内容查看
            $(".lookBtn2").click(function () {
                var id = $(this).data('id');
                // 根据id查看详细内容
                $.get('/association/getRemarksById.do',{id:id},function (data) {
                    $("#inputModal .modal-body").html(data.data);
                    $("#inputModal").modal('show');
                })
            })

            //全选/全不选
            $("#allCb").click(function () {
                //获取当前复选框checked状态,设置到table中的所有复选框
                $(".cb").prop('checked',$(this).prop('checked'))
            })

            //table中的复选框
            $(".cb").click(function () {
                //获取table中已经勾选的复选框的数量 , 判断是否等于table中的所有复选框的数量
                $("#allCb").prop('checked',$(".cb:checked").length == $(".cb").length)
            })

            //批量删除
            $(".btn_batchDelete").click(function () {
                //获取勾选的数据
                //判断是否有选中,如果没有需要先提示选中
                if($(".cb:checked").length == 0){
                    $.messager.alert("警告","请先选中数据!");
                    return;
                }
                //把选中的员工的id存到在ids
                var cbs = $(".cb:checked");
                var ids = [];
                $.each(cbs,function (index, ele) {
                    ids.push($(ele).data('id'));
                })
                /* var ids = $.map(cbs,function (ele) {
                     return $(ele).data('id');
                 })*/

                //如果有,提示确认框是否删除
                $.messager.confirm("警告","请确认是否进行删除?",function () {
                    $.post('/association/batchDelete.do',{ids:ids},handlerMessage)
                })
            })

            //导入按钮
            $(".btn-import").click(function () {
                $("#myModal").modal('show');
            })

            $(".btn-submit").click(function () {
                $("#editForm").ajaxSubmit(function () {
                    window.location.reload();
                });
            })


            // 审核通过
            $(".hotBtn1").click(function () {   // 审核通过
                var hot = $(this).data("hot");
                var id = $(this).data("id");
                $.get("/association/passOne", {hot:hot, id:id}, function (data) {
                    if(data.code == 200){
                        window.location.reload();
                    }else{
                        $.messager.alert("温馨提示", data.msg);
                    }
                })
            })
            // 审核拒绝
            $(".hotBtn2").click(function () {   // 审核拒绝
                var hot = $(this).data("hot");
                var id = $(this).data("id");
                $.get("/association/passOne", {hot:hot, id:id}, function (data) {
                    if(data.code == 200){
                        window.location.reload();
                    }else{
                        $.messager.alert("温馨提示", data.msg);
                    }
                })
            })

            // 删除
            $(".btn_delete").click(function () {
                var id = $(this).data('id');
                //提示确认框
                $.messager.confirm("警告","是否确认删除?",function () {
                    //发送ajax请求
                    $.get('/association/delete.do',{id:id},function (data) {
                        if(data.code == 200){ //用alert或者popup都可以
                            window.location.reload();
                        }else{
                            $.messager.alert("温馨提示", data.msg);
                        }
                    })
                });
            });

        })
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../../common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu="association"/>
    <#include "../../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>社团信息管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <div style="margin: 10px;">
                    <form class="form-inline" id="searchForm" action="/association/list.do" method="post">
                        <input type="hidden" name="currentPage" id="currentPage" value="1">
                        <div class="form-group">
                            <label for="keyword">关键字：</label>
                            <input type="text" class="form-control" id="keyword" name="keyword" value="${qo.keyword!}" placeholder="请输入社团/邮箱/创始人">
                        </div>
                        &nbsp;
                        <div class="form-group">
                            <label for="keyword">社团负责人：</label>
                            <input type="text" class="form-control" id="dutyer" name="dutyer" value="${qo.dutyer!}" placeholder="请输入社团负责人">
                        </div>
                        &nbsp;
                        <div class="form-group">
                            <label for="keyword">指导老师：</label>
                            <input type="text" class="form-control" id="teachername" name="teachername" value="${qo.teachername!}" placeholder="请输入指导老师的名字">
                        </div>
                        &nbsp;
                        <div class="form-group">
                            <label for="status"> 审核：</label>
                            <select class="form-control" id="status" name="status">
                                <option value="-1">全部</option>
                                <option value="0">待审核</option>
                                <option value="1">审核通过</option>
                                <option value="2">审核拒绝</option>
                            </select>
                            <script>
                                $("#status").val(${qo.status!});
                            </script>
                        </div>
                        &nbsp;
                        <button id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span> 查询</button>
                        <a href="/association/input.do" class="btn btn-success btn_redirect">
                            <span class="glyphicon glyphicon-plus"></span> 添加
                        </a>

                        <a href="JavaScript:;" class="btn btn-danger  btn_batchDelete">
                            <span class="glyphicon glyphicon-trash"></span> 批量删除
                        </a>

                        <a href="/association/exportXls.do" class="btn btn-warning" >
                            <span class="glyphicon glyphicon-download"></span> 导出
                        </a>

                        <a href="JavaScript:;" class="btn btn-warning btn-import">
                            <span class="glyphicon glyphicon-upload"></span> 导入
                        </a>

                    </form>
                </div>
                <table class="table table-hover table-bordered">
                    <thead>
                    <tr>
                        <th><input type="checkbox" id="allCb"></th>
                        <th>序号</th>
                        <th>图片</th>
                        <th>社团编号</th>
                        <th>社团名称</th>
                        <th>创始人</th>
                        <th>人数</th>
                        <th>社团负责人</th>
                        <th>负责人电话</th>
                        <th>指导老师</th>
                        <th>每年活动个数</th>
                        <th>每年活动总时长</th>
                        <th>状态</th>
                        <th>简介</th>
                        <th>备注</th>
                        <th>审核</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <#list page.list as association>
                        <tr>
                            <td><input type="checkbox" class="cb" data-id="${association.id}"></td>
                            <td>${association_index+1}</td>
                            <td><img src="${(association.imgUrl)!'/images/default.jpg'}" width="50px" id="imgUrl"></td>
                            <td>${association.number!}</td>
                            <td>${(association.username)!}</td>
                            <td>${(association.founder)!}</td>
                            <td>${(association.person)!}</td>
                            <td>${association.dutyName!}</td>
                            <td>${association.dutyMobile!}</td>
                            <td>${(association.teacher)!}</td>
                            <td>${association.activityNumber!}</td>
                            <td>${association.day!}</td>
                            <td>
                                <#if association.isAgree == 0 >
                                    审核中
                                <#elseif association.isAgree == 1>
                                    通过
                                <#elseif association.isAgree == 2>
                                    失败
                                </#if >
                            </td>
                            <td>
                                <a class="btn btn-info btn-xs lookBtn1" href="JavaScript:;" data-json='${association.synopsis!}'>
                                    查看简介
                                </a>
                            </td>
                            <td>
                                <a class="btn btn-info btn-xs lookBtn2" href="JavaScript:;" data-id="${association.id}">
                                    详细内容
                                </a>
                            </td>
                            <td>
                                <a class="btn btn-success btn-xs hotBtn1" href="javascript:;" data-hot='1' data-id="${association.id}">
                                    <span class="glyphicon glyphicon-minus-sign"></span> 通过
                                </a>

                                <a class="btn btn-danger btn-xs hotBtn2" href="JavaScript:;" data-hot="2" data-id="${association.id}">
                                    <span class="glyphicon glyphicon-tag"></span> 拒绝
                                </a>
                            </td>
                            <td>
                                <a href="/association/input.do?id=${association.id}" class="btn btn-info btn-xs btn_redirect">
                                    <span class="glyphicon glyphicon-pencil"></span> 编辑
                                </a>
                                <a href="javascript:;" class="btn btn-danger btn-xs btn_delete" data-id="${association.id}">
                                    <span class="glyphicon glyphicon-trash"></span> 删除
                                </a>
                            </td>
                        </tr>
                    </#list>
                </table>
                <!--分页-->
                <#include "../../common/page.ftl">
            </div>
        </section>
    </div>
    <#include "../../common/footer.ftl">
</div>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">导入</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/association/importXls.do" method="post" id="editForm">
                    <input type="hidden" name="id">
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="name" class="col-sm-3 control-label"></label>
                        <div class="col-sm-6">
                            <input type="file" name="file">
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 10px;">
                        <div class="col-sm-3"></div>
                        <div class="col-sm-6">
                            <a href="/xlstemplates/association.xls" class="btn btn-success" >
                            <span class="glyphicon glyphicon-download"></span> 下载模板
                            </a>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary btn-submit">保存</button>
            </div>
        </div>
    </div>
</div>

<!-- 大图显示 -->
<div id="ShowImage_Form" class="modal fade" >
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body" >
            </div>
        </div>
    </div>
</div>

<script>
    $("table img").click(function(){
        var src = $(this).attr("src");
        $("#ShowImage_Form .modal-body").html("<img src='"+src+"' class='carousel-inner img-responsive img-rounded' />");
        $("#ShowImage_Form").modal('show');
    })
</script>

<!-- 模态框必须作为body的子标签 -->
<div class="modal fade" id="inputSynModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalSynLabel">查看简介</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="" method="post" id="editForm1">
                    <div class="form-group">
                        <div class="col-sm-12">
                            <textarea rows="10" style="min-width: 100%" name="synopsis"></textarea>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="inputModal" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">详细内容</h4>
            </div>
            <div class="modal-body" >

            </div>
        </div>
    </div>
</div>

<style>
    #inputModal img{
        width: 570px !important;
    }
</style>



</body>
</html>
